package com.zky.seckillzky.seckill.controller;

import com.zky.common.utils.R;
import com.zky.seckillzky.seckill.rabbit.MQSender;
import com.zky.seckillzky.seckill.redis.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MqDemoController {

    @Autowired
    private RedisService redisService;


    @Autowired
    MQSender sender;

    //4
    @RequestMapping("/mq/header")
    @ResponseBody
    public R header() {
        sender.sendHeader("helloWorld");
        return  R.ok().put("success","Hello，world");
    }
    //3订阅发布  分类模式
    @RequestMapping("/mq/fanout")
    @ResponseBody
    public R fanout() {
        sender.sendFanout("helloWorld");
        return  R.ok().put("success","Hello，world");
    }
    //2主题模式  取消了过滤条件就是发布订阅了
    @RequestMapping("/mq/topic")
    @ResponseBody
    public R topic() {
        sender.sendTopic("helloWorld");
        return  R.ok().put("success","Hello，world");
    }
    //1 点对点
    @RequestMapping("/mq")
    @ResponseBody
    public R mq() {
        sender.send("helloWorld");
        return  R.ok().put("success","Hello，world");
    }

}
